//
//  Shake.swift
//  Maze24
//
//  Created by Mars on 2020/12/20.
//

import SwiftUI

struct Shake: GeometryEffect {
  var amount: CGFloat = 10
  var shakesPerUnit = 3
  var animatableData: CGFloat

  func effectValue(size: CGSize) -> ProjectionTransform {
    let x = amount * sin(animatableData * .pi * CGFloat(shakesPerUnit))
    let transform = CGAffineTransform(translationX: x, y: 0)
    return ProjectionTransform(transform)
  }
}
